package cn.itcast.service.company.impl;

import cn.itcast.dao.company.CompanyDao;
import cn.itcast.domain.company.Company;
import cn.itcast.service.company.CompanyService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;


import java.util.List;

@Service/*使用dubbo注解  提供服务*/
public class CompanyServiceImpl implements CompanyService {


    @Autowired
    private CompanyDao companyDao;
    @Override
    public List<Company> findAll() {
        List<Company> companyList = companyDao.findAll();

        return companyList;
    }

    @Override
    public void save(Company company) {
        companyDao.save(company);
    }

    @Override
    public Company findById(String id) {
        return companyDao.findById(id);
    }

    @Override
    public void update(Company company) {
        companyDao.update(company);
    }

    @Override
    public void deleteById(String id) {
        companyDao.deleteById(id);
    }

    @Override// PageInfo等同于我们自定义的pageBean 并且比pageBean更完善
    public PageInfo<Company> findByPage(Integer pageNum, Integer pageSize) {

        PageHelper.startPage(pageNum,pageSize);

        List<Company> list = companyDao.findAll();

        return new PageInfo<Company>(list,5);
    }
}
